export default {
	components: {

	},
	onLoad() {
		this.menuHeight = uni.getStorageSync('menuHeight');
		this.curAddressGetPoint = uni.getStorageSync('cur_address_point');
	},
	data() {
		return {
			menuHeight: 0,
			page: {
				page: 1,
				page_size: 10
			},
			goodsList: {
				lists: [],
				total: 1,
				total_page: 0
			},
			loadMoreStatus: 'loadmore',
			curAddressGetPoint: {},

		}
	},
	methods: {
		backPage() {
			uni.navigateBack();
		},
		goLink(url) {
			uni.navigateTo({
				url
			})
		},
		getProductList({
			team_id,
			team_category_id,
			keyword,
			team_active_id,
			with_buy,
			select_product_ids,
			$is_new
		}, type) {
			return new Promise((reslove, reject) => {
				if (type) {
					this.page.page = 1;
					this.goodsList = {
						lists: [],
						total: 2,
						total_page: 0
					}
				}
				let parmas = {
					...this.page,
					team_id,
					team_category_id,
					keyword,
					team_active_id,
					with_buy,
					select_product_ids,
					$is_new
				};
				console.log('搜索了ma', parmas);
				this.getList('goodsList', 'getProductList', 'page', parmas).then(res => {
					reslove();
				});
			})
		},
		getList(obj, api, page, params) {
			console.log('搜索了ma', obj, api);
			return new Promise((reslove, reject) => {
				if (this[obj].lists.length < this[obj].total || this[obj].lists.length < this[obj]
					.total_num) {
					this.loadMoreStatus = 'loading';
					this.$api[api](params).then(res => {
						this[obj].lists = [...this[obj].lists, ...res.data.lists];
						this[obj].total = res.data.total;
						this[page].page++;
						this[obj].total_page = res.data.total_page;
						this[obj].total_num = res.data.total_num;
						if (res.data.total == this[obj].lists.length || res.data.total_num == this[obj]
							.lists
							.length) {
							this.loadMoreStatus = 'nomore';
						} else {
							this.loadMoreStatus = 'loadmore';
						}
						reslove(res.data);
					});
				}
			})
		},
		numberToFix(val) {
			val *= 1;
			return val.toFixed(1);
		}
	}
}